﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;

using Happy.ExtentionMethods;

namespace Happy.Test.Infrastructure.ExtentionMethods
{
    [TestClass]
    public class CheckTest
    {
        [TestMethod]
        public void TheCorrespondingDirectoryMustExist_DirectoryExist_Test()
        {
            Environment.CurrentDirectory
                .TheCorrespondingDirectoryMustExist();
        }

        [ExpectedException(typeof(ApplicationException))]
        [TestMethod]
        public void TheCorrespondingDirectoryMustExist_DirectoryNotExist_Test()
        {
            Path
                .Combine(Environment.CurrentDirectory, "不存在的目录")
                .TheCorrespondingDirectoryMustExist();
        }


        [ExpectedException(typeof(ApplicationException))]
        [TestMethod]
        public void MustNotNullAndNotWhiteSpace_Null_String_Test()
        {
            string nullStr = null;

            nullStr.MustNotNullAndNotWhiteSpace("nullStr");
        }

        [ExpectedException(typeof(ApplicationException))]
        [TestMethod]
        public void MustNotNullAndNotWhiteSpace_White_Space_String_Test()
        {
            string whiteSpaceStr = " ";

            whiteSpaceStr.MustNotNullAndNotWhiteSpace("whiteSpaceStr");
        }


        [ExpectedException(typeof(ApplicationException))]
        [TestMethod]
        public void MustNotEmpty_Empty_Test()
        {
            var emptyCollection = new List<string>();

            emptyCollection.MustNotEmpty("emptyCollection");
        }


        [ExpectedException(typeof(ApplicationException))]
        [TestMethod]
        public void MustNotNull_Null_Test()
        {
            object nullOjb = null;

            nullOjb.MustNotNull("nullOjb");
        }


        [TestMethod]
        public void Require_Test()
        {
            Check.Require(Guid.NewGuid() != Guid.NewGuid(), "Guid.NewGuid()必须每次都返回不同的值");
        }
    }
}
